package com.erp.module.article

import android.content.Context
import com.erp.Interface.OnUserDataInterface
import com.erp.bean.ArticleBean
import com.erp.contacts.Contacts
import com.erp.util.Httputil
import com.erp.util.Httputil.getparams
import com.erp.util.Myutil.dateToStamp
import org.xutils.http.RequestParams
import org.xutils.x



/**
 * Created by Administrator on 2019/3/30/030.
 * 作者：刘洋
 */
class ArticleModel {
    /**获取卡诺亚资料列表 */
    fun Article(context: Context, page: Int, pagesize: Int,acbean : ArticleBean.ArticleSouSuo, onUserDataInterface: OnUserDataInterface) {
        val params = RequestParams(Contacts.ARTICLE)
        Httputil.getparams(context, params)
        Httputil.setProsess(params)
        params.addBodyParameter("page", page.toString())
        params.addBodyParameter("pagesize", pagesize.toString())
//        if (code == 0) {
//            params.addBodyParameter("searchParams[u_name_like]", searchParams)
//        } else if (code == 1) {
//            params.addBodyParameter("searchParams[alias_name]", searchParams)
//        } else if (code == 2) {
//            params.addBodyParameter("searchParams[esi_id_num]", searchParams)
//        }
        params.addBodyParameter("searchParams[title]", acbean.title)
        for (i in 0 until acbean.c.size){
            params.addBodyParameter("searchParams[type][$i]", acbean.c[i])
        }
        params.addBodyParameter("searchParams[time_filter][time_category]", "ka.uptime")
        if (acbean.starttime != "") {
            params.addBodyParameter("searchParams[time_filter][start_time]", dateToStamp(acbean.starttime))
        }
        if (acbean.endtime != "") {
            params.addBodyParameter("searchParams[time_filter][end_time]", dateToStamp(acbean.endtime))
        }
        x.http().get<String>(params, Httputil.Call(context, onUserDataInterface))
    }
    /**获取分类部门数据*/
    fun getArticleCategory(context: Context,onUserDataInterface: OnUserDataInterface){
        val params = RequestParams(Contacts.ARTICLECATEGORY)
        getparams(context, params)
        x.http().get(params, Httputil.Call(context, onUserDataInterface))
    }
}